// -----------------------------------------------------------------------------
// M A R I T I M E   R E S E A R C H   I N S T I T U T E   N E T H E R L A N D S
// -----------------------------------------------------------------------------
// Copyright (C) December 17, 2009 MARIN - All rights reserved - http://www.marin.nl
// -----------------------------------------------------------------------------
// Program  :
// Module   :
// File     : GeometryManager.cpp
// -----------------------------------------------------------------------------

#include <new>

#ifndef _WINDOWS
#include "mermaid.h"
#endif
#include "Geometry.h"
#include "GeometryManager.h"
#include "assertplus.h"

// -----------------------------------------------------------------------------
// function GeometryManager::GeometryManager
// -----------------------------------------------------------------------------
/// constructor
/** detailed description */
// -----------------------------------------------------------------------------
GeometryManager::GeometryManager()
: m_geometries()
{
}


// -----------------------------------------------------------------------------
// function GeometryManager::~GeometryManager()
// -----------------------------------------------------------------------------
/// destructor
/** detailed description */
// -----------------------------------------------------------------------------
GeometryManager::~GeometryManager()
{
    unsigned int n = (unsigned int)m_geometries.size();
    for (unsigned int i = 0; i < n; ++i)
    {
        delete m_geometries[i];
    }
}


Geometry* GeometryManager::getGeometry(int nr)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    return m_geometries[nr];
}


void GeometryManager::add(Geometry* a_pGeometry)
{
    m_geometries.push_back(a_pGeometry);
}


unsigned int GeometryManager::numberOfGeometries() const
{
    return (unsigned int)m_geometries.size();
}


const mml::Vector3d& GeometryManager::getPosition(int nr) const
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    return m_geometries[nr]->getPosition();
}


void GeometryManager::setPosition(int nr, const mml::Vector3d& position)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    m_geometries[nr]->setPosition(position);
}


void GeometryManager::setPositionOrientation(int nr, const mml::Vector3d& position, const mml::Vector3d& orientation)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    m_geometries[nr]->setPositionOrientation(position, orientation);
}


void GeometryManager::setPositionAttitude(int nr, const mml::Vector3d& position, const mml::Matrix3d& attitude)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    m_geometries[nr]->setPositionAttitude(position, attitude);
}


REAL GeometryManager::getAngle(int nr) const
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    return m_geometries[nr]->getAngle();
}


void GeometryManager::setAngle(int nr, REAL angle)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    m_geometries[nr]->setAngle(angle);
}


void GeometryManager::move(int nr, REAL deltaX, REAL deltaY)
{
    ASSERT((unsigned)nr < numberOfGeometries(), "no such ship");
    m_geometries[nr]->move(deltaX, deltaY);
}

